package io.ioscan.rzcoin.controller;

import io.ioscan.rzcoin.domain.Sms;
import io.ioscan.rzcoin.common.model.R;
import io.ioscan.rzcoin.service.SmsService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sms")
@RequiredArgsConstructor
public class SmsController {

    private final SmsService smsService;


    @PostMapping("/sendTo")
    @ApiOperation(value = "发送短信")
    @ApiImplicitParams({@ApiImplicitParam(name = "sms", value = "smsjson数据")})
    public R sendSms(@RequestBody @Validated Sms sms) {
        boolean isOk = smsService.sendSms(sms);
        if (isOk) {
            return R.ok();
        }
        return R.fail("发送失败");
    }
}
